package com.qf.boot2202.config;

import com.qf.boot2202.entity.User;
import com.qf.boot2202.service.HelloService;
import com.qf.boot2202.service.impl.MyHelloServiceImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

@Configuration  // 该注解使得这个类成为springboot 的一个配置类
public class MyConfig {

    @Bean   //该bean的 id 为方法名，即 myhelloService
    public HelloService myhelloService(){

        final MyHelloServiceImpl m = new MyHelloServiceImpl();

        return m;

    }

    @Bean
    @Scope("prototype")
    public User user01(){

        return new User(100, "luffy");

    }


    @Bean("user002")   // 更改bean在IOC容器中的 id 为 user002
    public User user02(){
        return  new User(200,"lisi");
    }

}
